﻿Imports System.Data
Imports System.Data.Odbc

Module modConexion
    Public cadenaString As String = "Dsn=bdcoprevi;uid=root"
    Public con As New OdbcConnection
    Public cmd As New OdbcCommand
    Public da As New OdbcDataAdapter
    Public dr As OdbcDataReader
    Public dt As New DataTable


    Public Sub conectar()
        con = New OdbcConnection
        con.ConnectionString = cadenaString
        Try
            con.Open()

        Catch ex As Exception
            mensajeError(ex)

        End Try


    End Sub


    Public Sub desconectar()
        Try
            cmd.Dispose()
            con.Dispose()
            con.Close()

        Catch ex As Exception
            mensajeError(ex)
        End Try
    End Sub


    Public Sub mensajeError(ByRef ex As Exception)
        MessageBox.Show("Error:" + ex.Message.ToString, "Coprevi", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Sub

End Module
